Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow BooleanField(null=True) on Django >= 2.1 #38

Closed
wants to merge 5 commits into from

Conversation

washeck
Copy link

@washeck washeck commented May 3, 2019

as this now recommened instead of using NullBooleanField.

as this now recommened instead of using NullBooleanField.
@washeck
Copy link
Author

washeck commented May 3, 2019

Changed in Django 2.1:

In older versions, this field doesn’t permit null=True, so you have to use NullBooleanField instead. Using the latter is now discouraged as it’s likely to be deprecated in a future version of Django.

@washeck
Copy link
Author

washeck commented Jun 21, 2019

@rocioar My PR fails because django is not importable in tests. Do you have suggestion how to fix it? I would expect django to be always installed when using flake8-django.

@rocioar
Copy link
Owner

rocioar commented Oct 27, 2019

@washeck As I mentioned on PR #41 we can fix it by creating a requirements file.

Thank you for contributing to the project!

@codecov-io
Copy link

Codecov Report

Merging #38 into master will decrease coverage by 0.49%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #38     +/-   ##
========================================
- Coverage     100%   99.5%   -0.5%     
========================================
  Files          17      11      -6     
  Lines         270     203     -67     
========================================
- Hits          270     202     -68     
- Misses          0       1      +1
Impacted Files Coverage Δ
flake8_django/checkers/model_fields.py 100% <100%> (ø) ⬆️
flake8_django/checkers/issue.py 90.9% <0%> (-9.1%) ⬇️
tests/test_urls.py
tests/test_model_form.py
tests/test_model_dunder_str.py
tests/test_model_fields.py
tests/test_render.py
tests/utils.py

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 917f196...686cba5. Read the comment docs.

as recommended in pytest-cov doc.
@washeck
Copy link
Author

washeck commented Nov 22, 2019

@rocioar I'm trying to fix it by running the coverage report from tox, inspired by django-money setup and pytest-cov documentation.

I'm not sure why it fails now but can you please review my PR and say if you are OK with this direction?

Copy link
Owner

@rocioar rocioar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for sending this PR. Sorry for taking so long to get back. Looking forward to having this PR merged.

]
NOT_BLANK_TRUE_FIELDS = ['BooleanField']
NOT_BLANK_TRUE_FIELDS = []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are failing now, because coverage decreases from 100% to 99% due to tests on test_model_fields where NOT_BLANK_TRUE_FIELDS is uses as a parameter. Since the list is empty this tests are not running, so that part of the code is not being covered.

I think, let's remove NOT_BLANK_TRUE_FIELDS altogether, since we could it's ok to have BooleanField with blank=True even in older version, that's just going to make the system use the default value.

What are your thoughts?

NOT_BLANK_TRUE_FIELDS = ['BooleanField']
NOT_BLANK_TRUE_FIELDS = []

if not ALLOW_NULL_BOOLEAN:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do the check for django.VERSION here? Just so that we make it more explicit?

skip_install = true
deps = coverage
commands =
coverage report --fail-under=100
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This report part is not needed, since coverage reports are being uploaded to codecov.

[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clean part is not needed.

django22-py{37,36}
django21-py{37,36,35}
django20-py{36,35,34}
report
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove clean and report from the envlist. We don't want to run coverage for every environment.

command: |
. venv/bin/activate
pip install -e .
py.test --cov=. --cov-fail-under=100
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this code, let's create a requirements/test.txt and add Django as a requirements for tests.

@rocioar
Copy link
Owner

rocioar commented Apr 10, 2020

Actually, I spent more time thinking about this, and I think we should actually drop support for Django < 2.1, since Django is no longer supporting those versions. That being said, we can remove this check altogether.

@washeck
Copy link
Author

washeck commented Apr 14, 2020

@rocioar Yes, removing this check makes sense to me.

@rocioar
Copy link
Owner

rocioar commented Apr 19, 2020

I've removed the check on: #60

@rocioar rocioar closed this Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants